import { replaceImage } from './regex'

export const replaceImageSrc = (index, filesObject, realFilesObject, content) => {
    const fn = (matchStr, capture) => {
        realFilesObject[capture] = filesObject[capture];
        if (matchStr) {
            return matchStr.replace(
                replaceImage,
                '<img src="file' + index++ + '"'
            );
        } else {
            return "";
        }
    };
    return content.replace(replaceImage, fn);
}